/**
 * My simple header template from child directory
 * Employee.java - ${projectName} - ${organizationName} - ${inceptionYear}
 */
package refactore;

/*
 * #%L
 * Ability-tester
 * %%
 * Copyright (C) 2014 SERKU
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

/**
 * User: Yahor Kastsialei
 * Date: 12/10/13
 * Time: 3:19 PM
 */
public class Employee {
    private Type type;
    private double base;
    private double achievements;
    private double companyResult;
    private double achievementsFactor;

    public static enum Type {
        SALES {
            public byte getAchievementModifier() {
                return 1;
            }

            public double getPercent() {
                return 0.0000001;
            }
        }, HR {
            public byte getAchievementModifier() {
                return 0;
            }

            public double getPercent() {
                return 0.0000002;
            }
        }, WORKER {
            public byte getAchievementModifier() {
                return 0;
            }

            public double getPercent() {
                return 0;
            }
        }, CEO {
            public byte getAchievementModifier() {
                return 1;
            }

            public double getPercent() {
                return 0.01;
            }
        };
        // 1 - employee get achievement bonus
        // 0 - not get
        public abstract byte getAchievementModifier();

        public abstract double getPercent();
    }

    public double getSalary() {
        return getBase()
                + getAchievementsFactor() * getAchievements() * type.getAchievementModifier()
                + getCompanyResult() * type.getPercent();
    }

    public void setType(Type type) {
        this.type = type;
    }

    public void setBase(double base) {
        this.base = base;
    }

    public double getBase() {
        return base;
    }

    public void setAchievements(double achievements) {
        this.achievements = achievements;
    }

    public double getAchievements() {
        return achievements;
    }

    public void setCompanyResult(double companyResult) {
        this.companyResult = companyResult;
    }

    public double getCompanyResult() {
        return companyResult;
    }

    public void setAchievementsFactor(double achievementsFactor) {
        this.achievementsFactor = achievementsFactor;
    }

    public double getAchievementsFactor() {
        return achievementsFactor;
    }
}